<?php 
    //Lay danh sach slide
    $content = array();
    $curDay = date('d-m-Y',time());
    $minusDay = date('d-m-Y', strtotime ( '-3 day' . $curDay ) ); 
    $minusDay = strtotime($minusDay);
    $condsDefault = $this->String->condsDefault();
    $condsDefault = array_merge($condsDefault,array('NOT' => array('NodeTerm.term_id' => 3),'Node.node_type_id' => 3));
    $fields = $this->String->nodeFields();
    $fields = array_merge($fields,array('Node.field_embed_youtube','Node.field_attach_file')); 
    $order = $this->String->orderFields();
    $opt = array(
        'conditions' => $condsDefault,
        'find' => 'all',
        'fields' => $fields,
        'locale' => true,
        'order' => $order
    );
    $content = $this->String->get_data('Node','NodeTerm',$opt);
    $k = 1;$arrNew = array();
    $i = 0;
    if(!empty($content)){
        foreach($content as $x=>$y){
            $term = ClassRegistry::init('Node.Term')->find('first',array(
                    'conditions' => array('Term.id' => $y['NodeTerm']['term_id']),
                    'recursive' => -1
                ));
            $content[$x]['Term'] = $term['Term'];
        }
        foreach($content as $key => $values){
            if($i%3==0) $k++;
            $arrNew[$k][] = $values;
            $i++; 
        }
    }
?>
<div class="asbl-r">
    <h3 class="tit-bd"><?php echo __d('default','Tin mới nhất');?></h3>
    <div class="asbl-rct asbl-rct-cus-slide">
        <div class="flexslider flexslider-cal">
            <ul class="slides">
                <?php if(!empty($arrNew)):?>
                    <?php foreach($arrNew as $key => $values):?>
                        <li>
                            <ul class="news-list-mn">
                                <?php foreach($values as $childKey => $childValues):?>
                                    <li class="item">
                                        <p class="date-post"> <?php echo date('d/m/Y',$childValues['Node']['created']);?> 
                                            <?php if($childValues['Node']['created']>$minusDay):?>
                                                <img src="<?php echo $this->Html->webroot('/images/front/newvn.gif');?>" alt="new" height="19" width="29" class="image-news"></p>
                                            <?php endif;?>
                                        <p class="tt-desc"><a href="<?php echo $this->Html->url(array('plugin' => 'View','controller' => 'View','action'=>'news',$childValues['Term']['alias'],$childValues['Node']['alias']));?>" class="ttlk"><?php echo String::truncate($childValues['Node']['title'],80);?></p>
                                    </li>
                                    <?php endforeach;?>
                            </ul>
                        </li>
                        <?php endforeach;?>
                    <?php endif;?>
            </ul>
        </div>
    </div>
</div>